home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / programer2 / icon / ReadMe next >
Text File  |  1991-06-23  |  12KB  |  311 lines

  1.                    Icon version 8 for the Archimedes
  2.                    ---------------------------------
  3.  
  4. There is very little here to say regarding this implementation of Icon
  5. for the Archimedes. It conforms fully to the standard Icon version 8
  6. documentation, ie. "The Icon Programming Language (2nd edition)" by R.E.
  7. and M.T. Griswold.
  8.  
  9. This version of Icon supports
  10.  
  11.         * Large Integers
  12.         * Co-expressions
  13.         * Keyboard functions (getch, getche, kbhit)
  14.         * The system() function
  15.  
  16. (which are the most often omitted features).
  17.  
  18. For the Archimedes, &features includes "Acorn Archimedes".
  19.  
  20.  
  21. Environment variables
  22. ---------------------
  23.  
  24. Icon uses a number of environment variables to set run-time values such
  25. as stack sizes or whether tracing is switched on. These are usually
  26. given names such as
  27.  
  28.         MSTKSIZE                Main stack size
  29.         TRACE                   Tracing on?
  30.  
  31. Following the usual Archimedes conventions, these variables have all
  32. been renamed, by prefixing the name with "Icon$". So, the above
  33. variables are called
  34.  
  35.         Icon$MStkSize           Main stack size
  36.         Icon$Trace              Tracing on?
  37.  
  38. and similarly for all "start-up" environment variables.
  39.  
  40.  
  41. File names
  42. ----------
  43.  
  44. As usual, the convention of using file name "extensions" causes
  45. difficulties. Icon uses four file extensions, namely
  46.  
  47.         .icn                    Icon source code
  48.         .u1                     Intermediate code (procedures)
  49.         .u2                     Intermediate code (globals)
  50.         .ux                     Linker diagnostics (-L flag)
  51.  
  52. Under RISC OS, the usual transformation is performed, ie. rather than
  53. looking for "file.icn", Icont looks for "Icn.file" - ie, file "file" in
  54. directory "Icn".
  55.  
  56. Similarly to Acorn C, Icont expects the U1 and U2 directories to be set
  57. up in advance (and the Ux directory if -L is used). Also, note that an
  58. "extension" of .icn can be omitted from the file name in Icont, so that
  59. to compile and link "Icn.Hello", all you need is
  60.  
  61.         Icont hello
  62.  
  63. The convention of using an "extension of .u to mean .u1 and .u2 is
  64. retained. So, to link U1.hello, U2.hello, U1.options and U2.options,
  65. giving an output file called HelloW, all that is needed is
  66.  
  67.         Icont -o HelloW U.hello U.options
  68.  
  69. Note that, UNLIKE Acorn C, filenames cannot be written in the
  70. "extension" form, so that
  71.  
  72.         Icont -o HelloW hello.u options.u
  73.  
  74. is WRONG.
  75.  
  76. Also, note that if compiling stdin (via Icont -, or simply Icont with no
  77. parameters) the output files are U1.Stdin, U2.Stdin and Stdin (the
  78. I-code executable).
  79.  
  80.  
  81. Standard search path
  82. --------------------
  83.  
  84. When looking for files named in "link" statements, Icon looks in places
  85. specified in the IPATH environment variable (called Icon$Ipath on the
  86. Archimedes). The default for this variable, when not set, is
  87.  
  88.         "Icon: Lib:Icon."
  89.  
  90. Icon therefore first looks along the RISC OS path specified by the OS
  91. variable Icon$Path, and if the file is not found, it then looks for a
  92. directory "Icon" on Lib$Path.
  93.  
  94. To alter the search path, two methods can be used. First, the value of
  95. Icon$Ipath can be altered. In this case, the Icon form of path,
  96. consisting of a space-separated list of directory prefixes, is used. An
  97. alternative method is to leave the default IPATH, but set up a suitable
  98. Icon$Path variable.
  99.  
  100. The second method is recommended, as it conforms better to the standard
  101. conventions under RISC OS. (A third possibility, to install a directory
  102. Icon somewhere on Lib$Path, is possible. This is a good idea for people
  103. like me, who keep all their language run-time stuff somewhere on
  104. Lib$Path).
  105.  
  106.  
  107. File types
  108. ----------
  109.  
  110. Icont will timestamp the executable I-code file, giving it file type
  111. "Icon" if such a file type exists. Ie, if <File$Type_xxx> is "Icon", for
  112. any xxx, then the I-code file is given file type xxx. This allows users
  113. to set up in their !Boot file
  114.  
  115.         Set File$Type_xxx       Icon
  116.         Set Alias$@RunType_xxx  Iconx %0 %*1
  117.  
  118. to make icon I-code files directly executable. (The %*1 allows for
  119. parameters being passed to the Icon program).
  120.  
  121.  
  122. Pipes
  123. -----
  124.  
  125. Archimedes Icon DOES support the opening of files as pipes (the "p"
  126. mode). This is done using temporary files. The input or output of the
  127. command is stored in a temporary file in one of the following places
  128. (tried in this order)
  129.  
  130.         <Tmp$Dir>       if this OS variable is set, and the directory exists
  131.         &.Tmp           if the directory exists
  132.         @               ie, the current directory
  133.  
  134. The temporary filenames are generated using random names, and so will not
  135. clash with existing files (hopefully!), and the temporary files will be
  136. deleted when they are finished with.
  137.  
  138. The IO redirection is done using the C convention ("command <in >out")
  139. for all but built-in commands (there is a hard-coded list of these). The
  140. built-in commands use OS redirection ("command { < in > out }") and the
  141. output file is post-processed to convert line separators "\r\n" into
  142. just "\n", which is what Icon expects.
  143.  
  144. If you want to run a program which is NOT a built-in, but which does
  145. not support the C convention (eg, basic or pascal programs), simply add
  146. a '%' to the front of the command (ie "%command arg arg..."). OS
  147. redirection will then be used, and the '%' removed. If you want to run
  148. a command starting with a '%', and STILL use C redirection, "*%command"
  149. should work (OS_CLI ignores leading asterisks).
  150.  
  151. Also, if you have the PD program "m4", which preprocesses files (giving
  152. C-like #define and #include facilities, plus much more, but with a
  153. different syntax), then you can use the "-m" flag to Icont, to
  154. preprocess your Icon code using m4.
  155.  
  156.  
  157. System Dependent Functions
  158. --------------------------
  159.  
  160. Archimedes Icon includes a number of low-level RISC OS interface
  161. functions, in a similar manner to MS-DOS ports of Icon. The relevant
  162. functions are
  163.  
  164. 1. Swi(swi,r0,r1,r2,...,r9)
  165.  
  166.    Swi(swi,r0,r1,r2,...,r9) is a general interface to the OS SWI
  167.    functions. The inputs are a SWI number (or name), and the values of
  168.    the registers r0 to r9. Any unused registers can be omitted. The
  169.    "swi" parameter is treated as a SWI number if it is an integer, and
  170.    a SWI name if it is a string. An invalid name results in run-time
  171.    error 205 (value out of range), and any type other than integer or
  172.    string results in run-time error 123 (invalid type).
  173.  
  174.    The registers, r0-r9, must be integer values. Any other type gives
  175.    run-time error 123 (invalid type). These are assigned to the relevant
  176.    register variables before the call. Note that an earlier version of
  177.    Archimedes Icon allowed Icon strings to be passed as register
  178.    parameters to Swi(). This is in fact highly insecure (due to the way
  179.    Icon handles strings - some details of which I was unaware of at the
  180.    time). In the current implementation, if you want to pass a string to
  181.    Swi(), use GetSpace(), Peek() and Poke() (see below). Remember that
  182.    Icon does not supply terminating NULL bytes on strings!
  183.  
  184.    If the SWI call fails (ie, an OS error occurs), Swi() fails (in the
  185.    Icon sense). Otherwise, the return value is a 10-element list,
  186.    holding the integer values of r0, ..., r9. To get at strings which
  187.    are returned as pointers, see Peek() below.
  188.  
  189.    Note that Swi() should not corrupt Icon's internal structures,
  190.    provided you pass the correct parameters to the swi. This was not
  191.    true in the earlier version. Obviously, such tricks as passing a
  192.    buffer, but lying about its length, will always cause problems! To
  193.    get a safe buffer, use GetSpace(), below.
  194.  
  195. 2. GetSpace(i)
  196.  
  197.    GetSpace(i) returns an integer, which is the address of a block of
  198.    storage, i bytes long. The storage is claimed using malloc(), and is
  199.    completely outside the control of Icon. The only way to read from or
  200.    write to this area, is using Peek() and Poke(), below.
  201.  
  202.    GetSpace() fails (in the Icon sense) if the memory is unavailable
  203.    (ie, malloc() returns NULL). This also happens if i is 0.
  204.  
  205. 3. FreeSpace(a)
  206.  
  207.    FreeSpace(a) frees the block of storage at address a (which must be
  208.    an integer), using free(). This should be used to free storage
  209.    allocated using GetSpace(). No check is made to make sure that a is
  210.    the address of an area claimed by GetSpace(). If it is not, you will
  211.    almost surely crash Icon.
  212.  
  213. 4. Peek(a,i)
  214.  
  215.    Peek(a,i) returns an Icon string, consisting of the i bytes at
  216.    address a. Peek() does not move any data about. It simply builds an
  217.    Icon string qualifier, pointing to the data. Hence the string
  218.    returned by Peek() is not modifiable.
  219.  
  220. 5. Poke(a,s)
  221.  
  222.    Poke(a,s) copies the Icon string s to address a. The string is copied
  223.    directly, byte by byte, with no conversion. No terminating null byte
  224.    is added. This is the only way of assigning data into a block of
  225.    storage allocated using GetSpace().
  226.  
  227. 6. Wildcard(l)
  228.  
  229.    Wildcard(l) takes a single string or a list of strings as its input
  230.    parameter. It processes each string in turn, treating it as a
  231.    filename which may contain wildcards. It expands the wildcards in the
  232.    usual RISC-OS manner, and produces a list of all matching filenames.
  233.    The return value from Wildcard() is a new list, containing the
  234.    expanded versions of all the input strings. This is best explained by
  235.    an example.
  236.  
  237.       Sources := Wildcard(["C.*", "H.*"])
  238.  
  239.    will assign to Sources a list of the filenames of all C source files
  240.    in the current directory.
  241.  
  242.    The function will often be used to provide wild-card expansion of
  243.    filenames specified on the command line of an Icon program. For
  244.    example, the following short Icon program will set all files
  245.    specified on the command line to "text" file type. It can be invoked
  246.    as (for example) "maketext C.* H.*".
  247.  
  248.       procedure main(args)
  249.          local file
  250.          args := Wildcard(args)
  251.          every file := !args do
  252.             system("Settype " || file || " text")
  253.       end
  254.  
  255. To go with these functions, &features includes "Archimedes extensions".
  256.  
  257.  
  258. Implementation notes
  259. --------------------
  260.  
  261. Unlike the standard Icon implementation, the C stack for a
  262. co-expression is allocated from the heap, using malloc(). This is
  263. necessary to support the built in Archimedes C stack extension
  264. facilities. The C stack is freed along with the other co-expression
  265. data structures. The code required to free the C stack relies on an
  266. undocumented feature of the internal routine coswitch() - see the
  267. source for details - and may not survive into future versions. It also
  268. was not present in the previous version of this port.
  269.  
  270.  
  271. Port information
  272. ----------------
  273.  
  274. This port was produced by
  275.  
  276. Paul Moore
  277.  
  278. 10, Mulberry Rise,
  279. Firdale Park,
  280. Northwich,
  281. Cheshire
  282. CW8 4UQ
  283.  
  284. E-Mail: pmoore@cix.UUCP
  285.         pmoore@cix.compulink.co.uk
  286.  
  287. I am interested in hearing about any bugs in the port, or any
  288. suggestions for improvements (although I will not put in any Archimedes
  289. specific alterations to the Icon language itself - I have registered
  290. this port with the Icon project, so that any upgrades will be
  291. automatically available).
  292.  
  293. This distribution may not include full source (depending upon where you
  294. got it from). If not, I can supply source. Please contact me (including
  295. a couple of FORMATTED disks), and I'll send a copy. Note: the sources
  296. are held as Spark archives, so you'll need to have Spark or the PD
  297. un-archiver SparkPlug to get at them. If you do not have SparkPlug
  298. (version 2 is required), then let me know so that I can include it with
  299. the distribution. The source requires Acorn's C, version 3.0, to
  300. compile, plus the Acorn ObjAsm assembler (for the file Asm.Rswitch), if
  301. you wish to include co-expressions. If you ask nicely, I can provide a
  302. pre-assembled O.Rswitch when I distribute the code.
  303.  
  304. I also have the rest of the Icon distribution (the Icon program library,
  305. Idol - an object-oriented front end for Icon, and a few other bits).
  306. Again, contact me, including disks, if you want them.
  307.  
  308. Have fun with Icon - it's an unusual, but nice, language.
  309.  
  310. Paul Moore
  311.